#ifndef ENGINE_H
#define ENGINE_H

#include <QtCore>
#include <QScriptEngine>

class Processor : public QThread
{
    Q_OBJECT
public:

    Processor(QString script);

    void receive(QString message);
    void link(Processor* processer);
public slots:
    void setStatus(QString name, QString value);
    QString getStatus(QString name);
    void broadcast(QString message);
    void log(QString message);




protected:
    virtual void run();
private:
    QMap<QString, QString> status;
    QScriptEngine scriptEngine;
    QList<Processor*> channels;
    QQueue<QString> messageQueue;
    QSemaphore semaphore;
    QString script;

};





class Engine
{
public:
    Engine(QString topology, QString algorithm);
    void run();
private:
    QList<Processor*> processors;
};


#endif // ENGINE_H
